package com.tiger.web.controller.project;

import com.tiger.common.core.domain.AjaxResult;
import com.tiger.common.core.domain.model.LoginUser;
import com.tiger.common.utils.ServletUtils;
import com.tiger.common.utils.spring.SpringUtils;
import com.tiger.framework.web.service.TokenService;
import com.tiger.project.service.ReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * @Author bai
 * Date on 2022/12/4  20:27
 * Description:
 */
@Api(tags = "生成PDF模板")
@RequestMapping("/project/report")
@RestController
public class ReportController {
    @Autowired
    private ReportService reportService;


    /**
     * 查询报告描述信息列表
     */
    @ApiOperation(value = "生成合同word文档")
    //@PreAuthorize("@ss.hasPermi('essential:describes:list')")
    @GetMapping("/generateReport")
    public AjaxResult generateReport(Long[] ids, String type) throws IOException {
        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
        reportService.generateReport(ids, loginUser.getUser().getDeptId(), type);
        return AjaxResult.success("生成中...");
    }
}
